class Solution:
    def reverseVowels(self, s: str) -> str:
        yuanyin_set = {"a", "e", "i", "o", "u", "A", "E", "I", "O", "U"}
        s_list = list(s)
        i, j = 0, len(s_list) - 1
        try:
            while True:
                while s_list[i] not in yuanyin_set:
                    i += 1
                while s_list[j] not in yuanyin_set:
                    j -= 1
                if i < j:
                    s_list[i], s_list[j] = s_list[j], s_list[i]
                    i += 1
                    j -= 1
                else:
                    break
        except:
            pass
        finally:
            return "".join(s_list)


a = Solution()
print(a.reverseVowels("hello"))
print(a.reverseVowels("leetcode"))
print(a.reverseVowels(""))
print(a.reverseVowels(" "))
